<template>
	<div>
		<el-form ref="form" :model="form" label-width="80px">

		<el-form-item label="姓名" prop="userName">
			<el-input v-model="form.userName"></el-input>
		</el-form-item>
		<el-form-item label="联系方式" prop="phoneNum">
			<el-input v-model="form.phoneNum"></el-input>
		</el-form-item>
		<el-form-item label="治疗处方" prop="therapeuticRegimen">
			<el-input v-model="form.therapeuticRegimen"></el-input>
		</el-form-item>
		<el-form-item label="治疗医师" prop="physician">
			<el-input v-model="form.physician"></el-input>
		</el-form-item>
		<el-form-item label="康复情况" prop="status">
			<el-input v-model="form.status"></el-input>
		</el-form-item>
		<el-form-item label="执行进度" prop="executeMuch">
			<el-input v-model="form.executeMuch"></el-input>
		</el-form-item>
			<el-form-item>
				<el-button type="primary" @click="save">保存</el-button>
			</el-form-item>
		</el-form>
	</div>
</template>

<script>
	export default {
		name: 'KfRecordEdit',
		components: {

		},
		props: ['editreId'],
		data() {
			return {
				form: {
					userName: '',
					phoneNum: '',
					therapeuticRegimen: null,
					physician: '',
					status: '',
					executeMuch:''
				},
				url: '/kfRecord/add'
			}
		},
		created() {
			console.log("this.editreId:" + this.editreId)
			if (this.editreId) {
				this.url ='/kfRecord/update'
				this.axios.get('/kfRecord/toedit', resp => {
					this.form.reId = resp.obj.reId
					this.form.userName = resp.obj.userName
					this.form.phoneNum = resp.obj.phoneNum
					this.form.therapeuticRegimen = resp.obj.therapeuticRegimen
					this.form.physician = resp.obj.physician
					this.form.status = resp.obj.status
					this.form.executeMuch = resp.obj.executeMuch
				}, {
					reId: this.editreId
				})
			}
		},
		methods: {

			save() {
				this.$refs['form'].validate((valid) => {
					if (valid) {
						this.axios.post(this.url, response => {
							// 子组件要改变父组件的值
							this.$emit('update:show', false)
							this.$emit('getData')
						}, this.form)
					}
				})
			}
		}
	}
</script>
<style>
</style>
